package goleetcode

func isWinner(player1 []int, player2 []int) int {
	value1 := calValue(player1)
	value2 := calValue(player2)
	if value1 > value2 {
		return 1
	} else if value1 < value2 {
		return 2
	}
	return 0
}

func calValue(array []int) int{
	res := 0
	for i, x := range array {
		if i > 0 && array[i - 1] == 10 || i > 1 && array[i - 2] == 10 {
			res += 2 * x
		} else {
			res += x
		}
	}
	return res
}